import BuffUtil from '@/BuffUtil';
import MathUtil from '@/MathUtil';
import SelectUtil from '@/SelectUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import { physicalDamageConfig } from 'code/Core/System/Configs/DamageConfig';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 战神打击
 **/
export default class ZS_MarsHit extends AbilityBase {
    static instance: ZS_MarsHit;
    buffType: AppBuffType = {
        id: 'buff_ZS_MarsHit',
        art: this.art,
        name: this.abilityName,
        ubertip: '受到战神打击影响，护甲降低了',
        dur: 6,
        targetAttach: 'overhead',
        targetArt: 'Abilities\\Spells\\NightElf\\ThornsAura\\ThornsAuraDamage.mdl',
        attribute: {
            基础护甲: -10,
            护甲百分比: -0.3,
        },
    };
    constructor(id: string = 'Azsj') {
        super(id);
        ZS_MarsHit.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        let { x, y } = MathUtil.polarProjection(GetUnitX(source), GetUnitY(source), 175, GetUnitFacing(source));
        DestroyEffect(AddSpecialEffect('Abilities\\Spells\\Human\\Thunderclap\\ThunderClapCaster.mdl', x, y));
        let es = SelectUtil.getEnemyUnitsInRange(source, 175, x, y);
        for (let e of es) {
            // BuffUtil.addBuff(e, this.buffType.id, source);
            BuffCommon.addBuff({ target: e, caster: source, buffTypeId: this.buffType.id, ablityId: this.id });
        }
        let dmg = (40 + UnitCommon.取攻击(source) * 0.6) * this.getAbilityLevel(source);
        DamageSystemInstance.applyAoeDamage(es, source, dmg, { ...physicalDamageConfig, abilityId: this.id });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
}
